<?php

namespace App\Models;

use Illuminate\Database\Eloquent\SoftDeletes;

class ArticleTag extends Base
{
    protected $guarded = [];

    // 软删除
    use SoftDeletes;

    //添加文章和标签的对应关系

    /**
     * @param $articleId  文章id
     * @param $TagsId  标签id数组
     */
    public static function addArticleTag($articleId,$TagsId)
    {
        foreach ($TagsId as $v)
        {
            $data = array("article_id"=>$articleId, "tag_id"=>$v);
            self::create($data);
        }
    }

}
